<?php
require_once( '../system/smarty.inc' );
require_once( '../system/mdao/Class_M_USER.php' );
require_once( '../system/mdao/Class_M_OTHER.php' );
require_once( '../system/Class_PWD.php' );
require_once( '../system/Class_ERROR.php' );
$dao = new Class_M_USER;
if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
	    $err = new Class_ERROR;
		$chk = $dao->get_checks();
	     $forms = $_POST;
	     $forms['local_name'] = $_POST['local_cd'];
	     $forms['birthday_year'] = $_POST['year4'];
	     $forms['birthday_m'] =    $_POST['moon4']; 
 $err_mes['login_id']=$err->exist_check($forms['login_id']);
	    $err_mes['login_pwd']=$err->exist_check($forms['login_pwd']);
	    $err_mes['user_name1']=$err->exist_check($forms['user_name1']);
	    $err_mes['user_name2']=$err->exist_check($forms['user_name2']);
	    $err_mes['user_name_furikana1']=$err->exist_check($forms['user_name_furikana1']);
	    $err_mes['user_name_furikana2']=$err->exist_check($forms['user_name_furikana2']);
	    $err_mes['zipcode1']=$err->exist_check($forms['zipcode1']);
	    $err_mes['zipcode2']=$err->exist_check($forms['zipcode2']);
	    $err_mes['local_cd']=$err->exist_check($forms['local_cd']);
	    $err_mes['street_name']=$err->exist_check($forms['street_name']);
	    $err_mes['address']=$err->exist_check($forms['address']);
	    $err_mes['tel_number1']=$err->exist_check($forms['tel_number1']);
	    $err_mes['tel_number2']=$err->exist_check($forms['tel_number2']);
	    $err_mes['tel_number3']=$err->exist_check($forms['tel_number3']);
	    $err_mes['email'] =$err->exist_check($forms['email']);
	    
	    if($err->clear){
	     $err_mes['email']=$err->mail_check($forms['email']);
         $err_mes['zipcode']=$err->zipcode_check($forms['zipcode1'].'-'.$forms['zipcode2']);
         $err_mes['tel_number']=$err->tel_check($forms['tel_number1'].'-'.$forms['tel_number2'].'-'.$forms['tel_number3']);    
         $err_mes['login_id']=$err->alnum_check($forms['login_id']);
         $err_mes['login_pwd']=$err->alnum_check($forms['login_pwd']);
	    }
	
	      if($err->clear){
	        $values["login_id"]  =  $forms['login_id'] ;
			$values["login_pwd"] =  $forms['login_pwd'] ;
			$values["user_name1"] =  $forms['user_name1'] ;
			$values["user_name2"] =  $forms['user_name2'] ;
			$values["user_name_furikana1"] =  $forms['user_name_furikana1'] ;
			$values["user_name_furikana2"] =  $forms['user_name_furikana2'] ;
			$values["workshop_name"] =  $forms['workshop_name'] ;
			$values["workshop_name_furikana"] = $forms['workshop_name_furikana'] ;
			$values["zipcode"] =  $forms['zipcode1'].$forms['zipcode2'];
			$values["local_name"] =  $forms['local_cd'];
			$values["street_name"] =$forms['street_name'];
			$values["address"] =$forms['address'];
			$values["tel_number"] =$forms['tel_number1'].$forms['tel_number2'].$forms['tel_number3'];
			$values["mobile_number"] =$forms['mobile_number1'].$forms['mobile_number2'].$forms['mobile_number3'];
			$values["email"] =$forms['email'];
			$values["send"] =$forms['send'];
			$values["sex"] =$forms['sex'];
			$values["state"] =$forms['state'];
			$values["birthday"] =$forms['year4'].'-'.$forms['moon4'].'-01';

			$dao->add($values);
	      }
}


$dao_local = Class_M_OTHER::get_local_array('都道府県');
$smarty->assign('year4',  Class_PWD::get_years() );
$smarty->assign('moon4',  Class_PWD::get_moons() );


if( isset($dao_local)) $smarty->assign('dao_local', $dao_local);
if( isset( $forms ) ) $smarty->assign('forms', $forms);
if( isset( $err_mes ) ){
	$smarty->assign('err', $err_mes);

}

$smarty->display('user_regist.html');
?>